package com.tanhua.server.springmvcConfig;

/**
 * @Author: cl
 * @Date: 2022/5/2 - 05 - 02
 * @Description:
 */

import com.tanhua.server.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new TokenInterceptor())
                //需要拦截的路径(拦截所有)
                .addPathPatterns("/**")
                //设置不需要拦截的路径(登录的发送验证码)
                .excludePathPatterns("/user/login","/user/loginVerification");

    }
}
